<template>
  <div class="">
    <top @add="save" />
    <con :list="list" />
  </div>
</template>

<script>
import top from "../components/zy3top";
import con from "../components/zy3con";
//获取当前年月日星期几几点几分几秒并打印
function getTimer() {
  var date = new Date();
  var week = [
    "星期日",
    "星期一",
    "星期二",
    "星期三",
    "星	期四",
    "星期五",
    "星期六"
  ];
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var datee = date.getDate();
  var day = date.getDay();
  var time = year + "年" + month + "月" + datee + "日 	" + week[day];
  function getTimerr() {
    var time = new Date();
    var hour = time.getHours();
    hour = hour < 10 ? "0" + hour : hour;
    var minute = time.getMinutes();
    minute = minute < 10 ? "0" + minute : minute;
    var second = time.getSeconds();
    second = second < 10 ? "0" + second : second;
    return hour + ":" + minute + ":" + second;
  }
  return time + " " + getTimerr();
}
export default {
  data() {
    return {
      list: [
        { sid: 1, name: "三国演义", time: getTimer() },
        { sid: 2, name: "红楼梦", time: getTimer() },
        { sid: 3, name: "西游记", time: getTimer() },
        { sid: 4, name: "水浒传", time: getTimer() }
      ]
    };
  },
  mounted() {},
  methods: {
    save(val1, val2) {
      this.list.push({
        sid: val1,
        name: val2,
        time: getTimer()
      });
    }
  },
  components: {
    top,
    con
  }
};
</script>

<style lang='scss'>
</style>
